package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import pojo.User;
import service.UserService;

@Controller
@RequestMapping("/user")
public class UserController {
    private UserService userService;

    @RequestMapping("/index")
    public String index(){
        return "index";
    }

    @RequestMapping("/login")
    public String login(User user){
        //登录逻辑
        boolean flag =userService.login(user);
        if(flag){
            return "index";
        }else{
            return "login";
        }
    }

    //全查询
    @RequestMapping("/list/{currentPage}")
    public String list(User user,@PathVariable("currentPage")int currentPage){

        return "list";
    }

    @RequestMapping("/register")
    public String register(){
        return "register";
    }

    @RequestMapping("/list")
    public String list(){
        userService.findAll(null,0,10);
        return "main";
    }
}
